<template>
  <div class="splash-screen" :class="{ 'fade-out': isClosing }" v-if="visible">
    <!-- 背景层 -->
    <div class="background-layer">
      <!-- 山峰背景 -->
      <div class="mountains">
        <div class="mountain mountain-1"></div>
        <div class="mountain mountain-2"></div>
        <div class="mountain mountain-3"></div>
        <div class="mountain mountain-4"></div>
      </div>
      
      <!-- 云朵装饰 -->
      <div class="clouds">
        <div class="cloud cloud-1"></div>
        <div class="cloud cloud-2"></div>
        <div class="cloud cloud-3"></div>
      </div>
      
      <!-- 渐变背景 -->
      <div class="gradient-overlay"></div>
    </div>

    <!-- 内容区域 -->
    <div class="content-area">
      <!-- 粒子效果 -->
      <div class="particles">
        <div v-for="i in 20" :key="i" class="particle" :style="getParticleStyle(i)"></div>
      </div>

      <!-- 光晕效果 -->
      <div class="glow-effects">
        <div class="glow glow-1"></div>
        <div class="glow glow-2"></div>
        <div class="glow glow-3"></div>
      </div>

      <!-- Logo区域 -->
      <div class="logo-section" :class="{ 'animate': showContent }">
        <div class="logo-container">
          <div class="logo-icon">
            <!-- 添加旋转的装饰环 -->
            <div class="decoration-ring ring-1"></div>
            <div class="decoration-ring ring-2"></div>
            <div class="decoration-ring ring-3"></div>

            <svg width="40" height="40" viewBox="0 0 24 24" fill="currentColor">
              <path d="M12,2C8.13,2 5,5.13 5,9C5,14.25 12,22 12,22C12,22 19,14.25 19,9C19,5.13 15.87,2 12,2M12,11.5A2.5,2.5 0 0,1 9.5,9A2.5,2.5 0 0,1 12,6.5A2.5,2.5 0 0,1 14.5,9A2.5,2.5 0 0,1 12,11.5Z"/>
            </svg>

            <!-- 闪烁的星星 -->
            <div class="sparkles">
              <div class="sparkle sparkle-1">✨</div>
              <div class="sparkle sparkle-2">⭐</div>
              <div class="sparkle sparkle-3">💫</div>
              <div class="sparkle sparkle-4">✨</div>
            </div>
          </div>
        </div>

        <h1 class="app-title">
          <span class="title-main">
            <span class="letter" v-for="(letter, index) in '测试'" :key="index" :style="{ animationDelay: (index * 0.1) + 's' }">
              {{ letter }}
            </span>
          </span>
          <span class="title-sub">
            <span class="letter" v-for="(letter, index) in '廉洁文化地图'" :key="index" :style="{ animationDelay: (index * 0.05 + 0.5) + 's' }">
              {{ letter }}
            </span>
          </span>
        </h1>
      </div>

      <!-- 播放按钮 -->
      <!-- <div class="play-section" :class="{ 'animate': showPlayButton }">
        <div class="play-button" @click="startExperience">
          <div class="play-icon">
            <svg width="24" height="24" viewBox="0 0 24 24" fill="currentColor">
              <path d="M8,5.14V19.14L19,12.14L8,5.14Z"/>
            </svg>
          </div>
        </div>
      </div> -->

      <!-- 开始按钮 -->
      <div class="start-section" :class="{ 'animate': showStartButton }">
        <button class="start-button" @click="startExperience">
          <span>点此出发</span>
          <span class="go-text">GO</span>
        </button>
      </div>

      <!-- 底部装饰 -->
      <div class="bottom-decoration">
        <div class="decoration-circle circle-1"></div>
        <div class="decoration-circle circle-2"></div>
      </div>
    </div>

    <!-- 顶部标题 -->
    <!-- <div class="top-title" :class="{ 'animate': showContent }">
      
    </div> -->

    <!-- 关闭按钮 -->
    <button class="close-button" @click="closeSplash" :class="{ 'animate': showContent }">
      <svg width="20" height="20" viewBox="0 0 24 24" fill="currentColor">
        <path d="M19,6.41L17.59,5L12,10.59L6.41,5L5,6.41L10.59,12L5,17.59L6.41,19L12,13.41L17.59,19L19,17.59L13.41,12L19,6.41Z"/>
      </svg>
    </button>
  </div>
</template>

<script>
export default {
  name: 'SplashScreen',
  data() {
    return {
      visible: true,
      isClosing: false,
      showContent: false,
      showPlayButton: false,
      showStartButton: false
    }
  },
  mounted() {
    // 延迟显示内容，创建动画效果
    setTimeout(() => {
      this.showContent = true
    }, 500)
    
    setTimeout(() => {
      this.showPlayButton = true
    }, 1000)
    
    setTimeout(() => {
      this.showStartButton = true
    }, 1500)
  },
  methods: {
    startExperience() {
      this.closeSplash()
    },
    closeSplash() {
      this.isClosing = true
      setTimeout(() => {
        this.visible = false
        this.$emit('close')
      }, 600)
    },
    getParticleStyle(index) {
      const size = Math.random() * 6 + 2
      const left = Math.random() * 100
      const animationDelay = Math.random() * 3
      const animationDuration = Math.random() * 3 + 2

      return {
        width: `${size}px`,
        height: `${size}px`,
        left: `${left}%`,
        animationDelay: `${animationDelay}s`,
        animationDuration: `${animationDuration}s`
      }
    }
  }
}
</script>

<style lang="scss" scoped>
.splash-screen {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  z-index: 9999;
  overflow: hidden;
  animation: fadeIn 0.8s ease-out;

  &.fade-out {
    animation: fadeOut 0.6s ease-in forwards;
  }
}

// 背景层
.background-layer {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: linear-gradient(180deg, 
    #a8e6cf 0%, 
    #7fcdcd 30%, 
    #81c784 60%, 
    #66bb6a 100%
  );
}

.gradient-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: linear-gradient(180deg, 
    rgba(255, 255, 255, 0.3) 0%, 
    rgba(255, 255, 255, 0.1) 50%, 
    rgba(255, 255, 255, 0.2) 100%
  );
}

// 山峰背景
.mountains {
  position: absolute;
  bottom: 0;
  left: 0;
  width: 100%;
  height: 60%;
}

.mountain {
  position: absolute;
  bottom: 0;
  background: linear-gradient(45deg, #4caf50, #66bb6a);
  opacity: 0.6;
  
  &::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(45deg, transparent 49%, rgba(255,255,255,0.3) 50%, transparent 51%);
  }
}

.mountain-1 {
  left: -10%;
  width: 40%;
  height: 80%;
  clip-path: polygon(0% 100%, 30% 20%, 60% 100%);
  animation: mountainSlide1 2s ease-out;
}

.mountain-2 {
  left: 20%;
  width: 35%;
  height: 70%;
  clip-path: polygon(0% 100%, 40% 10%, 80% 100%);
  animation: mountainSlide2 2.2s ease-out;
}

.mountain-3 {
  right: 10%;
  width: 45%;
  height: 85%;
  clip-path: polygon(0% 100%, 35% 15%, 70% 100%);
  animation: mountainSlide3 2.4s ease-out;
}

.mountain-4 {
  right: -15%;
  width: 40%;
  height: 75%;
  clip-path: polygon(0% 100%, 50% 25%, 100% 100%);
  animation: mountainSlide4 2.6s ease-out;
}

// 云朵装饰
.clouds {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
}

.cloud {
  position: absolute;
  background: rgba(255, 255, 255, 0.8);
  border-radius: 50px;
  
  &::before,
  &::after {
    content: '';
    position: absolute;
    background: rgba(255, 255, 255, 0.8);
    border-radius: 50px;
  }
}

.cloud-1 {
  top: 15%;
  left: 10%;
  width: 60px;
  height: 20px;
  animation: cloudFloat1 8s ease-in-out infinite;
  
  &::before {
    top: -10px;
    left: 10px;
    width: 30px;
    height: 30px;
  }
  
  &::after {
    top: -5px;
    right: 15px;
    width: 20px;
    height: 20px;
  }
}

.cloud-2 {
  top: 25%;
  right: 15%;
  width: 40px;
  height: 15px;
  animation: cloudFloat2 10s ease-in-out infinite;
  
  &::before {
    top: -8px;
    left: 8px;
    width: 20px;
    height: 20px;
  }
  
  &::after {
    top: -3px;
    right: 10px;
    width: 15px;
    height: 15px;
  }
}

.cloud-3 {
  top: 35%;
  left: 60%;
  width: 50px;
  height: 18px;
  animation: cloudFloat3 12s ease-in-out infinite;
  
  &::before {
    top: -9px;
    left: 12px;
    width: 25px;
    height: 25px;
  }
  
  &::after {
    top: -4px;
    right: 12px;
    width: 18px;
    height: 18px;
  }
}

// 粒子效果
.particles {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 5;
}

.particle {
  position: absolute;
  background: rgba(255, 255, 255, 0.8);
  border-radius: 50%;
  animation: particleFloat infinite ease-in-out;
}

// 光晕效果
.glow-effects {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 3;
}

.glow {
  position: absolute;
  border-radius: 50%;
  filter: blur(40px);
  opacity: 0.6;
}

.glow-1 {
  width: 200px;
  height: 200px;
  background: radial-gradient(circle, rgba(255, 255, 255, 0.3) 0%, transparent 70%);
  top: 20%;
  left: 10%;
  animation: glowFloat1 8s ease-in-out infinite;
}

.glow-2 {
  width: 150px;
  height: 150px;
  background: radial-gradient(circle, rgba(255, 255, 255, 0.2) 0%, transparent 70%);
  top: 60%;
  right: 15%;
  animation: glowFloat2 10s ease-in-out infinite;
}

.glow-3 {
  width: 180px;
  height: 180px;
  background: radial-gradient(circle, rgba(255, 255, 255, 0.25) 0%, transparent 70%);
  bottom: 30%;
  left: 50%;
  transform: translateX(-50%);
  animation: glowFloat3 12s ease-in-out infinite;
}

// 内容区域
.content-area {
  position: relative;
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 40px 20px;
  z-index: 10;
}

// Logo区域
.logo-section {
  text-align: center;
  margin-bottom: 60px;
  opacity: 0;
  transform: translateY(30px) scale(0.8);
  transition: all 1.2s cubic-bezier(0.175, 0.885, 0.32, 1.275);

  &.animate {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.logo-container {
  position: relative;
  display: inline-block;
  margin-bottom: 30px;
}

.logo-icon {
  position: relative;
  width: 100px;
  height: 100px;
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.95) 0%, rgba(255, 255, 255, 0.85) 100%);
  border-radius: 25px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto;
  color: #4caf50;
  box-shadow:
    0 15px 35px rgba(0, 0, 0, 0.1),
    0 5px 15px rgba(0, 0, 0, 0.07),
    inset 0 1px 0 rgba(255, 255, 255, 0.8);
  animation: logoFloat 4s ease-in-out infinite;
  backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 255, 255, 0.3);

  svg {
    filter: drop-shadow(0 2px 4px rgba(76, 175, 80, 0.3));
    animation: iconPulse 2s ease-in-out infinite;
  }
}

// 装饰环
.decoration-ring {
  position: absolute;
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-radius: 50%;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);

  &.ring-1 {
    width: 120px;
    height: 120px;
    animation: ringRotate1 8s linear infinite;
    border-top-color: rgba(76, 175, 80, 0.6);
  }

  &.ring-2 {
    width: 140px;
    height: 140px;
    animation: ringRotate2 12s linear infinite reverse;
    border-right-color: rgba(255, 255, 255, 0.6);
  }

  &.ring-3 {
    width: 160px;
    height: 160px;
    animation: ringRotate3 16s linear infinite;
    border-left-color: rgba(76, 175, 80, 0.4);
  }
}

// 闪烁星星
.sparkles {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

.sparkle {
  position: absolute;
  font-size: 16px;
  animation: sparkleFloat infinite ease-in-out;

  &.sparkle-1 {
    top: -10px;
    right: -10px;
    animation-duration: 2s;
    animation-delay: 0s;
  }

  &.sparkle-2 {
    bottom: -10px;
    left: -10px;
    animation-duration: 2.5s;
    animation-delay: 0.5s;
  }

  &.sparkle-3 {
    top: 50%;
    right: -20px;
    animation-duration: 3s;
    animation-delay: 1s;
  }

  &.sparkle-4 {
    bottom: 50%;
    left: -20px;
    animation-duration: 2.2s;
    animation-delay: 1.5s;
  }
}

.app-title {
  margin: 0;

  .title-main {
    display: block;
    font-size: 52px;
    font-weight: 900;
    color: #2e7d32;
    text-shadow:
      3px 3px 6px rgba(0, 0, 0, 0.1),
      0 0 20px rgba(76, 175, 80, 0.3);
    margin-bottom: 12px;

    .letter {
      display: inline-block;
      opacity: 0;
      transform: translateY(20px) rotateX(90deg);
      animation: letterDrop 0.8s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
    }
  }

  .title-sub {
    display: block;
    font-size: 20px;
    font-weight: 600;
    color: #4caf50;
    letter-spacing: 3px;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);

    .letter {
      display: inline-block;
      opacity: 0;
      transform: translateY(10px);
      animation: letterFade 0.6s ease-out forwards;
    }
  }
}

// 播放按钮
.play-section {
  margin-bottom: 40px;
  opacity: 0;
  transform: scale(0.8);
  transition: all 0.6s ease-out;
  
  &.animate {
    opacity: 1;
    transform: scale(1);
  }
}

.play-button {
  width: 80px;
  height: 80px;
  background: rgba(255, 255, 255, 0.9);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.15);
  transition: all 0.3s ease;
  animation: pulse 2s ease-in-out infinite;
  
  &:hover {
    transform: scale(1.1);
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.2);
  }
  
  .play-icon {
    color: #4caf50;
    margin-left: 4px;
  }
}

// 开始按钮
.start-section {
  opacity: 0;
  transform: translateY(20px);
  transition: all 0.6s ease-out;
  
  &.animate {
    opacity: 1;
    transform: translateY(0);
  }
}

.start-button {
  position: relative;
  background: linear-gradient(135deg, #ff6b6b 0%, #ff8e8e 50%, #ff6b6b 100%);
  background-size: 200% 200%;
  color: white;
  border: none;
  padding: 18px 36px;
  border-radius: 35px;
  font-size: 18px;
  font-weight: 700;
  cursor: pointer;
  box-shadow:
    0 10px 30px rgba(255, 107, 107, 0.4),
    0 5px 15px rgba(255, 107, 107, 0.2),
    inset 0 1px 0 rgba(255, 255, 255, 0.3);
  transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  display: flex;
  align-items: center;
  gap: 12px;
  animation: buttonGlow 3s ease-in-out infinite;
  overflow: hidden;

  &::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.4), transparent);
    transition: left 0.6s ease;
  }

  &:hover {
    transform: translateY(-4px) scale(1.05);
    box-shadow:
      0 15px 40px rgba(255, 107, 107, 0.6),
      0 8px 20px rgba(255, 107, 107, 0.3);
    background-position: 100% 0;

    &::before {
      left: 100%;
    }
  }

  &:active {
    transform: translateY(-2px) scale(1.02);
  }

  .go-text {
    background: rgba(255, 255, 255, 0.25);
    padding: 6px 12px;
    border-radius: 15px;
    font-size: 14px;
    font-weight: 800;
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.2);
    animation: goTextPulse 2s ease-in-out infinite;
  }
}

// 顶部标题
.top-title {
  position: absolute;
  top: 40px;
  left: 50%;
  transform: translateX(-50%);
  color: rgba(255, 255, 255, 0.9);
  font-size: 16px;
  font-weight: 600;
  z-index: 20;
  opacity: 0;
  transition: all 0.6s ease-out;
  
  &.animate {
    opacity: 1;
  }
}

// 关闭按钮
.close-button {
  position: absolute;
  top: 40px;
  right: 20px;
  width: 40px;
  height: 40px;
  background: rgba(255, 255, 255, 0.2);
  border: none;
  border-radius: 50%;
  color: rgba(255, 255, 255, 0.8);
  cursor: pointer;
  z-index: 20;
  opacity: 0;
  transition: all 0.3s ease;
  
  &.animate {
    opacity: 1;
  }
  
  &:hover {
    background: rgba(255, 255, 255, 0.3);
    color: white;
  }
}

// 底部装饰
.bottom-decoration {
  position: absolute;
  bottom: 40px;
  left: 50%;
  transform: translateX(-50%);
}

.decoration-circle {
  position: absolute;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.3);
}

.circle-1 {
  width: 60px;
  height: 60px;
  left: -30px;
  animation: decorationFloat1 4s ease-in-out infinite;
}

.circle-2 {
  width: 40px;
  height: 40px;
  right: -50px;
  animation: decorationFloat2 5s ease-in-out infinite;
}

// 动画定义
@keyframes fadeIn {
  from {
    opacity: 0;
    transform: scale(1.1);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

@keyframes fadeOut {
  from {
    opacity: 1;
    transform: scale(1);
  }
  to {
    opacity: 0;
    transform: scale(0.95);
  }
}

@keyframes mountainSlide1 {
  from {
    transform: translateX(-100%);
    opacity: 0;
  }
  to {
    transform: translateX(0);
    opacity: 0.6;
  }
}

@keyframes mountainSlide2 {
  from {
    transform: translateX(-100%);
    opacity: 0;
  }
  to {
    transform: translateX(0);
    opacity: 0.6;
  }
}

@keyframes mountainSlide3 {
  from {
    transform: translateX(100%);
    opacity: 0;
  }
  to {
    transform: translateX(0);
    opacity: 0.6;
  }
}

@keyframes mountainSlide4 {
  from {
    transform: translateX(100%);
    opacity: 0;
  }
  to {
    transform: translateX(0);
    opacity: 0.6;
  }
}

@keyframes cloudFloat1 {
  0%, 100% {
    transform: translateX(0) translateY(0);
  }
  50% {
    transform: translateX(20px) translateY(-10px);
  }
}

@keyframes cloudFloat2 {
  0%, 100% {
    transform: translateX(0) translateY(0);
  }
  50% {
    transform: translateX(-15px) translateY(-8px);
  }
}

@keyframes cloudFloat3 {
  0%, 100% {
    transform: translateX(0) translateY(0);
  }
  50% {
    transform: translateX(10px) translateY(-12px);
  }
}

@keyframes logoFloat {
  0%, 100% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(-10px);
  }
}

@keyframes pulse {
  0%, 100% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.05);
  }
}

@keyframes decorationFloat1 {
  0%, 100% {
    transform: translateY(0) rotate(0deg);
  }
  50% {
    transform: translateY(-15px) rotate(180deg);
  }
}

@keyframes decorationFloat2 {
  0%, 100% {
    transform: translateY(0) rotate(0deg);
  }
  50% {
    transform: translateY(-20px) rotate(-180deg);
  }
}

// 新增动画
@keyframes particleFloat {
  0% {
    transform: translateY(100vh) rotate(0deg);
    opacity: 0;
  }
  10% {
    opacity: 1;
  }
  90% {
    opacity: 1;
  }
  100% {
    transform: translateY(-100px) rotate(360deg);
    opacity: 0;
  }
}

@keyframes glowFloat1 {
  0%, 100% {
    transform: translate(0, 0) scale(1);
    opacity: 0.6;
  }
  50% {
    transform: translate(30px, -20px) scale(1.2);
    opacity: 0.8;
  }
}

@keyframes glowFloat2 {
  0%, 100% {
    transform: translate(0, 0) scale(1);
    opacity: 0.4;
  }
  50% {
    transform: translate(-25px, 15px) scale(1.1);
    opacity: 0.7;
  }
}

@keyframes glowFloat3 {
  0%, 100% {
    transform: translateX(-50%) scale(1);
    opacity: 0.5;
  }
  50% {
    transform: translateX(-50%) translateY(-30px) scale(1.3);
    opacity: 0.8;
  }
}

@keyframes ringRotate1 {
  from {
    transform: translate(-50%, -50%) rotate(0deg);
  }
  to {
    transform: translate(-50%, -50%) rotate(360deg);
  }
}

@keyframes ringRotate2 {
  from {
    transform: translate(-50%, -50%) rotate(0deg);
  }
  to {
    transform: translate(-50%, -50%) rotate(-360deg);
  }
}

@keyframes ringRotate3 {
  from {
    transform: translate(-50%, -50%) rotate(0deg);
  }
  to {
    transform: translate(-50%, -50%) rotate(360deg);
  }
}

@keyframes sparkleFloat {
  0%, 100% {
    transform: translateY(0) scale(1);
    opacity: 0;
  }
  50% {
    transform: translateY(-10px) scale(1.2);
    opacity: 1;
  }
}

@keyframes iconPulse {
  0%, 100% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.1);
  }
}

@keyframes letterDrop {
  from {
    opacity: 0;
    transform: translateY(20px) rotateX(90deg);
  }
  to {
    opacity: 1;
    transform: translateY(0) rotateX(0deg);
  }
}

@keyframes letterFade {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes buttonGlow {
  0%, 100% {
    box-shadow:
      0 10px 30px rgba(255, 107, 107, 0.4),
      0 5px 15px rgba(255, 107, 107, 0.2),
      inset 0 1px 0 rgba(255, 255, 255, 0.3);
  }
  50% {
    box-shadow:
      0 15px 40px rgba(255, 107, 107, 0.6),
      0 8px 20px rgba(255, 107, 107, 0.4),
      inset 0 1px 0 rgba(255, 255, 255, 0.4);
  }
}

@keyframes goTextPulse {
  0%, 100% {
    transform: scale(1);
    background: rgba(255, 255, 255, 0.25);
  }
  50% {
    transform: scale(1.05);
    background: rgba(255, 255, 255, 0.35);
  }
}
</style>
